package com.colbby.datahouse.transform;

import com.colbby.datahouse.utils.CastUtils;
import com.colbby.datahouse.utils.TypeDescriptor;
import com.colbby.datahouse.utils.TypeUtils;

public class IntTransformer implements DataTypeTransform<Integer> {

	public static final IntTransformer INSTANCE = new IntTransformer();
	
	@Override
	public Integer transform(TypeDescriptor returnType, Object result) {
		return CastUtils.castToInteger(CastUtils.getValue(result));
	}

	@Override
	public boolean shouldDo(TypeDescriptor returnType, Object value) {
		return TypeUtils.isSuperClass(Integer.class, returnType.getTypeClass());
	}
}
